package com.example.e_comm.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("roles")
@NoArgsConstructor
@AllArgsConstructor
public class Role {
    public Role(Long id, String name, String description, String roleKey){
        this.id = id;
        this.name = name;
        this.description = description;
        this.roleKey = roleKey;
        this.status = 1;
        this.deleted = 0;
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;//角色名
    private String description;//描述

    @TableField(value = "role_key")
    private String roleKey;//角色标识，用于权限校验
    private Integer status;//状态，0：禁用，1：正常

    @TableLogic(value = "0",delval = "1")
    private Integer deleted;//逻辑删除字段，0：未删除，1：已删除

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime = LocalDateTime.now();
    @TableField(value = "update_time",fill = FieldFill.UPDATE)
    private LocalDateTime updateTime = LocalDateTime.now();

    //关联关系，根据角色进行角色分配权限
    @TableField(exist = false)
    private List<Permission> permissions; //角色权限列表

}
